package com.wondertek.liveroom;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.util.Log;
import android.view.ViewGroup;

public class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {
	private static final String TAG = "MyFragmentPagerAdapter";
	public static final int FRAGMENT_0 = 0;
	public static final int FRAGMENT_1 = 1;
	public static final int FRAGMENT_2 = 2;
	public static final int FRAGMENT_3 = 3;
	
	private int curTab = 0;
	private FragmentManager fm = null;
	
	public MyFragmentPagerAdapter(FragmentManager fm) {
		super(fm);
		curTab = 0;
		this.fm = fm;
		// TODO Auto-generated constructor stub
	}
	
	public MyFragmentPagerAdapter(FragmentManager fm, int tab) {
		super(fm);
		curTab = tab;
		this.fm = fm;
		// TODO Auto-generated constructor stub
	}

	@Override
	public Fragment getItem(int index) {
		//Log.e("getItem", "getItemgetItemgetItem     " +index);
		switch(curTab) {
		case 0:
			return MyFragmentFactory.createFragment(index);
		case 1:
			return MyFragmentFactory.createLiveFragment(index);
		case 2:
			return MyFragmentFactory.createVideoFragment(index);
		case 3:
			return new FragmentMine();
		}
		return null;
	}

	@Override
	public int getCount() {
		//Log.e("getCount", "getCountgetCountgetCountgetCount     ");
		switch (curTab) {
			case 0:
				return 1;
			case 1:
				return 8;
			case 2:
				return 8;
			case 3:
				return 1;
			default:
				return 0;
		}
	}
}
